package io.renren.modules.clienthome.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.utils.CommonBusinessStatus;
import io.renren.common.utils.R;
import io.renren.modules.clienthome.service.ClientHomeService;
import io.renren.modules.companys.dao.CompanyDao;
import io.renren.modules.companys.entity.CompanyEntity;
import io.renren.modules.companys.service.CompanyService;
import io.renren.modules.resumes.dao.ResumeDao;
import io.renren.modules.resumes.entity.ResumeEntity;
import io.renren.modules.resumes.service.ResumeService;
import io.renren.modules.telnets.dao.TalentsRepertoryDao;
import io.renren.modules.telnets.entity.TalentsRepertoryEntity;
import io.renren.modules.telnets.service.TalentsRepertoryService;
import io.renren.modules.workjobs.dao.WorkJobDao;
import io.renren.modules.workjobs.entity.WorkJobEntity;
import io.renren.modules.workjobs.service.WorkJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/client_home")
@RestController
public class ClientHomeController {

    @Autowired
    private ClientHomeService clientHomeService;

    @Autowired
    private ResumeService resumeService;
    @Autowired
    private ResumeDao resumeDao;

    @Autowired
    private CompanyService companyService;
    @Autowired
    private CompanyDao companyDao;

    @Autowired
    private WorkJobService workJobService;
    @Autowired
    private WorkJobDao workJobDao;

    @Autowired
    private TalentsRepertoryService talentsRepertoryService;
    @Autowired
    private TalentsRepertoryDao talentsRepertoryDao;


    @RequestMapping("/workInfo")
    public R excellentWorkJob(){
        R r = clientHomeService.excellentWorkJob();
        return r;
    }

    @RequestMapping("/talentsInfo")
    public R talentsInfo(){
        R r = clientHomeService.talentsInfo();
        return r;
    }


















    /*后台首页信息展示*/
    @GetMapping("/companyTotal")
    public R companyInCount(){
        QueryWrapper<CompanyEntity> companyWrapper = new QueryWrapper<>();
        companyWrapper.eq("is_pass",1)
                      .eq("company_approve_status", CommonBusinessStatus.COMPANY_HAVE_APPROVE);

        List<CompanyEntity> companyEntities = companyDao.selectList(companyWrapper);
        return R.ok().put("total",companyEntities.size());
    }

    @GetMapping("/talnetTotal")
    public R talnetCount(){
        List<TalentsRepertoryEntity> talentsRepertoryEntities = talentsRepertoryDao.selectList(null);
        return R.ok().put("total",talentsRepertoryEntities.size());
    }

    @GetMapping("/workJobTotal")
    public R  workJobCount(){
        QueryWrapper<WorkJobEntity> workJobWrapper = new QueryWrapper<>();
        workJobWrapper.eq("job_is_pass",1)
                      .eq("job_approve_status",CommonBusinessStatus.POSITION_HAVE_APPROVE);
        List<WorkJobEntity> workJobEntities = workJobDao.selectList(workJobWrapper);
        return R.ok().put("total",workJobEntities.size());
    }

    @GetMapping("/resumeTotal")
    public R resumeCount(){
        QueryWrapper<ResumeEntity> resumeWrapper = new QueryWrapper<>();
        resumeWrapper.eq("is_pass",1)
                .eq("resume_approve_status",CommonBusinessStatus.RESUME_HAVING_APPROVE);
        List<ResumeEntity> resumeEntities = resumeDao.selectList(resumeWrapper);
        return R.ok().put("total",resumeEntities.size());
    }
}
